﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 菜鸟教程_事件案例2
{
    class DelegateTest
    {
        public delegate void delegate_tz();

        public event delegate_tz delegate_tz0;

        public void start()
        {
            Console.WriteLine("启动事件");
            delegate_tz0();      // 得调用该事件呀
            Console.ReadKey();
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            DelegateTest DelegateTest0 = new DelegateTest();
            //DelegateTest0.delegate_tz0 += DelegateTest.delegate_tz(test);  // 必须new一下才行，因为它是另外一个类呀
            DelegateTest0.delegate_tz0 += new DelegateTest.delegate_tz(test);//注册事件
            DelegateTest0.start();// 启动事件
            Console.ReadKey();

        }

        static public void test()
        {
            Console.WriteLine("这是一个被注册的函数，按任意键继续...");
            Console.ReadKey();
        }
    }
}
